package com.woniu.service;

import com.woniu.dao.ManagerDao;
import com.woniu.entity.Admins;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author WenXin
 * @version 1.0
 * @description: TODO
 * @date 2022/8/20 19:34
 */
@Service(value = "rms")//默认类名小写开头
public class RbacManagerServiceImpl implements RbacManagerService {
    @Autowired//自动注入注解
    public void setDao(ManagerDao dao) {
        this.dao = dao;
    }


    //dao
    private ManagerDao dao;

    @Override
    public int add(int a, int b) {
        System.out.println("a + b =" + (a + b));
        return a + b;
    }

    @Override
    public void find() {
        System.out.println("执行find方法");
    }

    //增
    @Transactional
    @Override
    public int insert(String user, String pwd) {
        int insert = dao.insert(user, pwd);
        int a = 1 / 0;
        return insert;
    }

    //删
    @Override
    public int delete(int id) {
        int i = dao.delete(id);
        return i;
    }

    @Override
    //改
    public int update(Admins admins) {
        int i = dao.update(admins);
        return i;
    }

    //查
    @Override
    public Admins findOne(int id) {
        return dao.findOne(id);
    }

    //查全部
    @Override
    public List<Admins> findAll() {
        System.out.println("执行findAll方法");
        return dao.findAll();
    }
}
